﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;
using BCCommon;
using BCEntity.OA.Workflow.WorkflowActivityStepExtendMethod;
using Dapper;

namespace BCData.OA.Workflow.WorkflowActivityStepExtendMethod
{
    public class WorkflowActivityStepExtendMethodData: IWorkflowActivityStepExtendMethodData
    {
        private readonly IDatabaseContext databaseContext;
        private const string QUERY = @"SELECT WorkflowActivityStepExtendMethodId,WorkflowActivityId,TaskStep,ExtendMethodCode,ExtendMethodName,ExtendMethodTitle,TaskServiceName,TaskMethodName,
                                            TaskMethodParameters,IsCustom,GotoStep
                                        FROM OA_WorkflowActivityStepExtendMethod";
        public WorkflowActivityStepExtendMethodData(IDatabaseContext databaseContext)
        {
            this.databaseContext=databaseContext;
        }

        public async Task<IEnumerable<WorkflowActivityStepExtendMethodEntity>> Get(long workflowActivityId)
        {
            string sql = string.Format("{0} WHERE WorkflowActivityId=?WorkflowActivityId", QUERY);
            DynamicParameters parameters = new DynamicParameters();
            parameters.Add("?WorkflowActivityId", workflowActivityId, DbType.Int64, size: 20);
            return await this.databaseContext.Slave.QueryAsync<WorkflowActivityStepExtendMethodEntity>(sql, parameters);
        }
    }
}
